home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 129_01.zip / CLRAY.C < prev    next >
Text File  |  1993-06-01  |  2KB  |  124 lines

  1. #include <210ctdl.h>    /* header file    */
  2.  
  3. main()
  4. {
  5.     int  index;
  6.     int i, entry, lstfl, pw;
  7.     char obuf[BUFSIZ];
  8.     
  9.     readsystab();
  10.     if ((logfl = open("ctdllog.sys",0)) == ERROR) {
  11.     printf("Can't open the Citadel log!\n");
  12.     exit();
  13.     }
  14.     pw = lstfl = 0;
  15.     entry = 1;
  16.     for ( i = 0; i < MAXLOGTAB; i++ ) {
  17.     printf("log #%d",i);
  18.     if (logTab[i].ltpwhash != 0 &&
  19.         logTab[i].ltnmhash != 0) {
  20.         getlog(&logBuf,logTab[i].ltlogSlot);
  21.         showlog(&logBuf,entry++,lstfl,obuf,pw); 
  22.     }
  23.     else {
  24.         putchar('\r');
  25.     }
  26.     }
  27. }
  28.  
  29. showlog(log,i,lst,buf,pw)
  30. struct logBuffer *log;
  31. int i,lst,pw;
  32. char *buf;
  33. {
  34.     int j;
  35.     char work[80],work2[80];
  36.     
  37.     sprintf(work,"%4d: %-20s",i,log->lbname);
  38.     if (pw) {
  39.     sprintf(work2,"%-20s",log->lbpw);
  40.     strcat(work,work2);
  41.     }
  42.     sprintf(work2," %sAide, %sExpert, %d col.\n",
  43.     log->lbflags & AIDE   ? "    " : "Not ", 
  44.     log->lbflags & EXPERT ? "    " : "Not ",
  45.     log->lbwidth);
  46.     strcat(work,work2);
  47.     printf("%s",work);
  48. }
  49.  
  50. /*
  51.  *    getLog() loads requested log record into RAM buffer
  52.  */
  53. getlog(lBuf, n)
  54. struct logBuffer *lBuf;
  55. int n;
  56. {
  57.     int sec;
  58.     if (lBuf == &logBuf)
  59.     thisLog = n;
  60.  
  61.     n *= SECSPERLOG;
  62.  
  63.     seek(logfl, n, 0);
  64.     if ( (sec = read(logfl, lBuf, SECSPERLOG) ) != SECSPERLOG ) {
  65.     printf("?getLog-rread fail, request was for %d", n/SECSPERLOG);
  66.     exit(printf("\n%s", errmsg(errno())));
  67.     }
  68.     crypte(lBuf, (SECSPERLOG*SECTSIZE), n);    /* decode buffer    */
  69. }
  70.  
  71. dumpsec(p)
  72. char *p;
  73. {
  74.     char c;
  75.     int i,j;
  76.  
  77.     for ( i = 0; i < 8; i++) {
  78.     for (j = 0; j < 16; j++)
  79.         printf(" %02x",p[i*16+j]);
  80.     printf("  |");
  81.     for (j = 0; j < 16; j++) {
  82.         c = p[i*16+j];
  83.         if (c < ' ' || c > 128)
  84.         putchar('.');
  85.         else
  86.         putchar(c);
  87.     }
  88.     printf("|\n");
  89.     }
  90.     putchar('\n');
  91. }
  92.  
  93. crypte(buf, len, seed)
  94. char      *buf;
  95. unsigned  len, seed;
  96. {
  97.     seed = (seed + 0x553) & 0xFF;
  98.     for ( ; len; len--) {
  99.     *buf++ ^= seed;
  100.     seed = (seed + CRYPTADD)  &  0xFF;
  101.     }
  102. }
  103.  
  104. /*
  105. **   readSysTab() restores state of system from SYSTEM.TAB
  106. */
  107. readSysTab()
  108. {
  109.     char getc();
  110.     char fBuf[BUFSIZ];
  111.     char *c;
  112.  
  113.     if(fopen("ctdlTabl.sys", fBuf) == ERROR)
  114.     exit(printf("?no ctdlTabl.sys!"));
  115.  
  116.     getw(fBuf);
  117.     getw(fBuf);
  118.     c = &firstExtern;
  119.     while (c < &lastExtern)
  120.     *c++ = getc(fBuf);
  121.     return(TRUE);
  122. }
  123. /SECSPERLOG);
  124.     exit(printf("\n%s",